//def
function trim(myString)
{
    return myString.replace(/^s+/g, '').replace(/s+$/g, '')
}
function change_page(offset, per_page)
{
    var current_uri = $('input[name=url]').val();

    var page = offset / per_page + 1;
    var url = '';
    if (current_uri.search('@') != -1)
        url = current_uri.replace('@', '/trang-' + page)
    else
        url = current_uri + '/trang-' + page;

    location.href = url;
    return;
}

function slide_scroll()
{
    var $root = $('html, body');
    $('a').click(function() {
        $root.animate({
            scrollTop: $( $.attr(this, 'href') ).offset().top
        }, 1500);
        return false;
    });
}

function show_fancy_box()
{
    $("a[rel=example_group]").fancybox({
        'overlayShow'	: false,
        'transitionIn'	: 'elastic',
        'transitionOut'	: 'elastic',
        'titlePosition' 	: 'over',
        'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
            return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
        }
    });
}

function sticky_scroller()
{
    
    var height = $('.main_s_d')[0].scrollHeight - $('#footer')[0].scrollHeight - 130;
    if(($('.main_s_d_detail')[0].scrollHeight) > 400)
        {
            StickyScroller(".side_bar",
                {
                    start: 250,
                    end: height,
                    interval: 100,
                    range: 0,
                    margin: 50
                });
        }
        
}